/**
 * Created by Coing on 2017/2/26.
 */
public class Solution_q {

    public int lengthOfLastWord(String s) {

        if(s==null|| "".equals(s.trim())){
            return 0;
        }
        else {
            String target[] = s.split(" ");//目标字符串数组
            String LastWord = target[target.length - 1];
            char[] chs = LastWord.toCharArray();
            System.out.println(chs.length);
            return chs.length;
        }

    }

    public static void main(String[] args) {
        Solution_q solution = new Solution_q();
        System.out.println(solution.lengthOfLastWord(""));
        System.out.println("**********");
        System.out.println(solution.lengthOfLastWord("  "));
        System.out.println("**********");
        System.out.println(solution.lengthOfLastWord("hello world"));
        System.out.println("**********");
        System.out.println(solution.lengthOfLastWord("  lls  sd 32 "));

    }

}
